<include file="public@header"/>
</head>
<>
<div calss="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('school/index')}">所有学校</a></li>
        <li><a href="{:url('school/add')}">添加学校</a></li>
        <li class="active"><a>编辑学校</a></li>
    </ul>
    <form class="form-horizontal js-ajax-form  margin-top-20" method="post" action="{:url('school/edit')}">
        <div class="form-group">
            <label for="input-province" class="col-sm-2 control-label">所在省份</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="province" id="input-province">
                    <foreach name="province" item="vo">
                        <if $data.province == $vo.areaId or $data.province == $vo.areaName>
                            <option value="{$vo.areaId}" selected>{$vo.areaName}</option>
                        <else />
                            <option value="{$vo.areaId}">{$vo.areaName}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-city" class="col-sm-2 control-label">所在城市</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="city" id="input-city">
                    <foreach name="city" item="vo">
                        <if $data.city == $vo.areaId or $data.city == $vo.areaName>
                            <option value="{$vo.areaId}" selected>{$vo.areaName}</option>
                            <else />
                            <option value="{$vo.areaId}">{$vo.areaName}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-area" class="col-sm-2 control-label">所在县区</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="area" id="input-area">
                    <foreach name="area" item="vo">
                        <if $data.area == $vo.areaId or $data.area == $vo.areaName>
                            <option value="{$vo.areaId}" selected>{$vo.areaName}</option>
                            <else />
                            <option value="{$vo.areaId}">{$vo.areaName}</option>
                        </if>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label"><span class="form-required">*</span>详细住址</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-address" name="address" value="{$data.address}" >
            </div>
        </div>
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label"><span class="form-required">*</span>学校名称</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-name" name="school" value="{$data.name}">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <input type="hidden" name="id" value="{$data.id}"/>
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('EDIT')}</button>
                <a class="btn btn-default" href="{:url('admin/school/index')}">{:lang('BACK')}</a>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    $(function () {
        $('#input-province').on('change',function () {
            var areaId = $(this).val();
            $.ajax({
                url:"{:url('school/getCity')}",
                type:"POST",
                data:{areaId:areaId},
                success:function (res) {
                    $('#input-city').html(res);
                    console.log(res);
                }
            })
        })
    })
</script>
<script>
    $(function () {
        $('#input-city').on('change',function () {
            var cityId = $(this).val();
            $.ajax({
                url:"{:url('school/getArea')}",
                type:"POST",
                data:{cityId:cityId},
                success:function (res) {
                    $('#input-area').html(res);
                    console.log(res);
                }
            })
        })
    })
</script>
</body>
</html>